<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="x-ua-compatible" content="IE=8"/>
        <link rel="stylesheet" type="text/css" href="styles10.css">
        <style type="text/css">
			html,body{
				padding:0;margin:0;
			}
            .container { font:caption; padding: 10px 25px; word-wrap: break-word; white-space: pre-wrap; } 
			#div_text{ padding-top:0px; padding-bottom:20px; 
				background: #ffffff; /* Old browsers */
				background: -moz-linear-gradient(top,  #ffffff 0%, #f0f0f0 100%); /* FF3.6-15 */
				background: -webkit-linear-gradient(top,  #ffffff 0%,#f0f0f0 100%); /* Chrome10-25,Safari5.1-6 */
				background: linear-gradient(to bottom,  #ffffff 0%,#f0f0f0 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
				filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f0f0f0',GradientType=0 ); /* IE6-9 */
			}

			
			#size_container {
				padding: 15px 25px 5px;
				background:#e0e0e0;
				border:1px solid #d0d0d0;			
			}
			#inter_text{padding: 20px 25px;}
			#input_container{
				background:#e0e0e0;
				padding: 10px 25px 20px;
				border:1px solid #d0d0d0;
				border-width:1px 0;
				overflow:visible;
			}
			#input_container input{width:98%; display:block}
			#input_container label{display:block; margin-bottom:3px; margin-top:15px;}
            .button_ok { position: absolute; right: 100px; bottom: 8px; } 
            .button_cancel { width: 70px; position: absolute; right: 15px; bottom: 8px; } 
			.button_ok_and_reset_cache, .button_ok_and_reset_cache:hover { position: absolute; left: 15px; bottom: 8px; width: auto; padding-left:10px; padding-right:10px; } 
			.titleBig {
				font-size:130%;
				font-style: italic;
				text-align:center;
				padding-bottom:0px;
			}
			.separator{width:50px; background:#000; height: 1px; margin: 15px auto 2px; }
        </style>
        <title></title>
    </head>
    <body>
        <div id="div_text" class="container"></div>
        <div id="input_container">			
		</div>			
        <div id="bottom_msg" class="container"></div>		
		<button id="btn_cancel" class="button_cancel">Cancel</button>		
        <button class="button_ok" id="btn_ok">Validate</button>		
        <script>   
            // helpers
            function close_window() {
                window.open('', '_self', '');
                window.close();
            }

            // parse data
            var parsed_args;
            var callback_fn;
            try {
                parsed_args = window.external.dialogArguments.toArray();
            }
            catch(e) {
            }
            if (parsed_args) {
                document.title = parsed_args[0];
				
				window.div_text.insertAdjacentHTML('beforeend',parsed_args[1]);
				
                var labelInnerHtml = window.btn_cancel.innerHTML;
                window.btn_cancel.innerHTML = labelInnerHtml.replace(/Cancel/g, parsed_args[2]);
                callback_fn = parsed_args[3];
				
				var input_labels = parsed_args[5];
				var input_labels = input_labels.split("##");	
				var input_default_values = parsed_args[6];
				var input_default_values = input_default_values.split("##");				
				for (var i = 0; i < input_labels.length; i++) {
				  window.input_container.insertAdjacentHTML('beforeend', '<div><label for="input_'+i+'">'+input_labels[i]+'</label><input id="input_'+i+'" name="inputs" value="'+input_default_values[i]+'"></input></div>');
				}		
				window.bottom_msg.insertAdjacentHTML('beforeend',parsed_args[4]);
            }
			
			var window_w = 558;
			var window_h = 425;
			window_h = 83 + window.div_text.offsetHeight + window.input_container.offsetHeight + window.btn_ok.offsetHeight + (parsed_args[4]!=""?window.bottom_msg.offsetHeight:0);
			if (window_w < window_h + 50) {
				window_w += 50;
				window.resizeTo(window_w, window_h);
				window_h = 83 + window.div_text.offsetHeight + window.input_container.offsetHeight + window.btn_ok.offsetHeight + (parsed_args[4]!=""?window.bottom_msg.offsetHeight:0);
			}
			window.resizeTo(window_w, window_h);
			
            window.btn_ok.onclick = function () {
				var inputs = document.getElementsByName('inputs');
				var inputs_values = inputs[0].value;
				for(var i = 0; i < inputs.length; i++){
						if(i>0) inputs_values += "##",
						inputs_values += inputs[i].value;
						//alert(inputs_values);
				}
                callback_fn && callback_fn("ok", inputs_values);
                close_window();
            };	
			document.onkeydown = function () {
				if (window.event.keyCode == 13 && window.btn_ok.onclick) {
					window.btn_ok.onclick();
				}
			};
            window.btn_cancel.onclick = function () {
				callback_fn && callback_fn("cancel", false);
                close_window();
            };
            window.document.body.focus();
            window.btn_ok.focus();
        </script>
    </body>
</html>